//
//  RYTUUID.m
//  DCSmart
//
//  Created by 郭豪豪 on 16/7/25.
//  Copyright © 2016年 郭豪豪. All rights reserved.
//

#import "RYTUUID.h"
#import "RYTKeyChainStore.h"

@implementation RYTUUID

+ (NSString *)getUUID {
    
    NSString * strUUID = (NSString *)[RYTKeyChainStore load:@"com.company.app.usernamepassword"];
    
    //首次执行该方法时，uuid为空
    if ([strUUID isEqualToString:@""] || !strUUID) {
        //生成一个uuid的方法
        CFUUIDRef uuidRef = CFUUIDCreate(kCFAllocatorDefault);
        
        strUUID = (NSString *)CFBridgingRelease(CFUUIDCreateString (kCFAllocatorDefault,uuidRef));
        
        //将该uuid保存到keychain
        [RYTKeyChainStore save:@"com.company.app.usernamepassword" data:strUUID];
    }
    return strUUID;
}

@end
